﻿<Page
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:Microsoft.Samples.Office.UnifiedCommunications.Gadget"
    xmlns:wf="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2006" 
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    mc:Ignorable="d"
    x:Class="Microsoft.Samples.Office.UnifiedCommunications.Gadget.Fav5Config"
    Title="Fav 5 Configuration" 
    ShowsNavigationUI="False" 
    ClipToBounds="True">
    
    <Page.Resources>
        <Storyboard x:Key="LoadAni">
            <local:BackDoubleAnimation Completed="BackDoubleAnimation_Completed" From="300" To="0" Duration="0:0:0.8" EdgeBehavior="EaseOut" Amplitude=".5" Suppression="0" DecelerationRatio=".5" Storyboard.TargetName="mainGrid" Storyboard.TargetProperty="(UIElement.RenderTransform).(TranslateTransform.X)"/>
        </Storyboard>

        <Style x:Key="textBoxStyleFav5" BasedOn="{x:Null}" TargetType="{x:Type TextBox}">
            <EventSetter Event="GotFocus" Handler="TextBox_GotFocus"/>
            <EventSetter Event="LostFocus" Handler="TextBox_LostFocus"/>
            <EventSetter Event="GotMouseCapture" Handler="TextBox_GotFocus"/>

            <Setter Property="SnapsToDevicePixels" Value="True"/>
            <Setter Property="OverridesDefaultStyle" Value="True"/>
            <Setter Property="KeyboardNavigation.TabNavigation" Value="None"/>
            <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
            <Setter Property="MinWidth" Value="120"/>
            <Setter Property="Height" Value="Auto" />
            <Setter Property="AllowDrop" Value="true"/>
            <Setter Property="Foreground" Value="#FF3D4F73" />
            <Setter Property="FontFamily" Value="Calibri" />
            <Setter Property="VerticalAlignment" Value="Center"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type TextBox}">
                        <Border 
                        x:Name="Border"
                        CornerRadius="2" 
                        Padding="2"            
                        BorderBrush="#FF3D4F73"
                        BorderThickness="1" >
                            <Border.Background>
                                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                    <GradientStop Color="#FFFFFFFF" Offset="0"/>
                                    <GradientStop Color="#FFFFFFFF" Offset="0.272"/>
                                </LinearGradientBrush>
                            </Border.Background>
                            <ScrollViewer Margin="0" x:Name="PART_ContentHost"/>
                        </Border>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsEnabled" Value="False" />
                            <Trigger Property="IsFocused" Value="True">
                                <Setter Property="Background" TargetName="Border">
                                    <Setter.Value>
                                        <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                            <GradientStop Color="#FFDCDCDC" Offset="0"/>
                                            <GradientStop Color="#FFFFFFFF" Offset="0.272"/>
                                        </LinearGradientBrush>
                                    </Setter.Value>
                                </Setter>
                                <Setter Property="BorderThickness" TargetName="Border" Value="1.3,1.3,1.3,1.3"/>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </Page.Resources>

    <Page.Triggers>
        <EventTrigger RoutedEvent="FrameworkElement.Loaded">
            <BeginStoryboard Storyboard="{StaticResource LoadAni}"/>
        </EventTrigger>
    </Page.Triggers>

    <Grid x:Name="mainGrid">
        <Grid.RenderTransform>
            <TranslateTransform X="0" Y="0"/>
        </Grid.RenderTransform>
        <Border BorderThickness="1,1,1,1" BorderBrush="#FF333945" CornerRadius="9,9,9,9">
            <Border Width="Auto" Height="Auto" BorderBrush="#FF161D25" BorderThickness="1,1,1,1" CornerRadius="8,8,8,8">
                <Grid Width="Auto" Height="Auto" x:Name="ContentGrid">
                    <Rectangle Stroke="{x:Null}" RadiusX="8" RadiusY="8" Width="Auto" Height="Auto" MinHeight="380" MinWidth="280">
                        <Rectangle.Fill>
                            <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                <GradientStop Color="#FFDAE3EF" Offset="0"/>
                                <GradientStop Color="#FFE2EBF1" Offset="1"/>
                            </LinearGradientBrush>
                        </Rectangle.Fill>
                    </Rectangle>
                    <TextBlock HorizontalAlignment="Center" VerticalAlignment="Top" Text="Fav 5 Configuration" TextWrapping="Wrap" Background="{x:Null}" Foreground="#FF3D4F73" FontFamily="Calibri" FontSize="16" FontWeight="Bold" Padding="0,10,0,0"/>
                    
                    <Grid x:Name="gridContent" Margin="5,40,5,35">
                        <Grid.Resources>                        
                            <ObjectDataProvider x:Key="clickActions" ObjectType="{x:Type local:DefaultClickActions}" />   
                        
                            <local:ClickActionConverterIM x:Key="clickActionConverterIM" />
                            <local:ClickActionConverterPhoneCall x:Key="clickActionConverterPhoneCall" />
                            <local:ClickActionConverterCommunicatorCall x:Key="clickActionConverterCommunicatorCall" />
                            <local:IsPhoneNumberConverter x:Key="isPhoneNumberConverter"/>
                            <local:IsEmptyFav5ContactIDConverter x:Key="isEmptyFav5ContactIDConverter" />
                            <local:IsEmptyFav5DisplayNameConverter x:Key="isEmptyFav5DisplayNameConverter" />
                                
                            <DataTemplate x:Key="fav5EntryTemplate">
                                <Grid Margin="0 0 0 10" ClipToBounds="False">
                                    <Grid.RowDefinitions>
                                        <RowDefinition />
                                        <RowDefinition />
                                    </Grid.RowDefinitions>

                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="125"/>
                                        <ColumnDefinition />
                                    </Grid.ColumnDefinitions>
                                    
                                    <Border x:Name="borderContactId" BorderBrush="#999999" Width="125" BorderThickness="1" Padding="0" CornerRadius="2" Grid.Column="0" Grid.Row="0" Margin="0 0 0 5" VerticalAlignment="Center">
                                        <Label x:Name="lblFav5ContactId"  
                                               MinWidth="125" Width="125" Height="Auto"
                                               Padding="2"
                                               Margin="0,0,0,0"
                                               FontFamily="Calibri" 
                                               Foreground="#FF3D4F73" Background="#6FFFFFFF" 
                                               Content="{Binding Path=ContactID, Mode=TwoWay}" 
                                               AllowDrop="True" Drop="Object_Drop" 
                                               Style="{Binding Path=ContactID, Converter={StaticResource isEmptyFav5ContactIDConverter}}"/>
                                    </Border>

                                    <Border x:Name="borderDisplayName" BorderBrush="#999999" Width="125" BorderThickness="1" Padding="0" CornerRadius="2" Grid.Column="0" Grid.Row="1" VerticalAlignment="Center">
                                        <Label x:Name="lblFav5DisplayName" 
                                               MinWidth="125" Width="125" Height="Auto" 
                                               Padding="2"
                                               Margin="0,0,0,0"
                                               FontFamily="Calibri"
                                               Foreground="#FF3D4F73" Background="#6FFFFFFF" 
                                               Content="{Binding Path=DisplayName, Mode=TwoWay}" 
                                               Style="{Binding Path=DisplayName, Converter={StaticResource isEmptyFav5DisplayNameConverter}}"/>
                                    </Border>
                                    
                                    <TextBox x:Name="txtFav5ContactId" Width="125" Style="{DynamicResource textBoxStyleFav5}" Text="{Binding Path=ContactID, Mode=TwoWay}" Visibility="Collapsed" Grid.Column="0" Grid.Row="0" Margin="0 0 0 5"/>
                                    <TextBox x:Name="txtFav5DisplayName" Width="125" Style="{DynamicResource textBoxStyleFav5}" Text="{Binding Path=DisplayName, Mode=TwoWay}" Visibility="Collapsed" Grid.Column="0" Grid.Row="1"/>
                                    
                                    <StackPanel Margin="10 0 0 0" Orientation="Horizontal" Grid.Column="2" Grid.RowSpan="2" VerticalAlignment="Center">
                                       <RadioButton x:Name="radioInstantMessage" GroupName="{Binding Path=Slot}"  Margin="0 0 5 0" ToolTip="Instant Message"
                                            IsEnabled="{Binding Path=IsPhoneNumber, Converter={StaticResource isPhoneNumberConverter}, Mode=OneWay}"
                                            IsChecked="{Binding Path=DefaultClickActionFriendlyName, Converter={StaticResource clickActionConverterIM}, Mode=OneWay}"
                                            Checked="radioDefaultClickAction_Checked" Tag="Instant Message">
                                           <RadioButton.Content>
                                               <Image Height="22" Width="19" Source="{DynamicResource chatIcon}" VerticalAlignment="Center" ToolTip="Instant Message" Margin="-3,0,0,0" />
                                           </RadioButton.Content>
                                        </RadioButton>
                                        <RadioButton x:Name="radioPhoneCall" GroupName="{Binding Path=Slot}" Margin="0 0 5 0" ToolTip="Phone Call"
                                            IsChecked="{Binding Path=DefaultClickActionFriendlyName, Converter={StaticResource clickActionConverterPhoneCall}, Mode=OneWay}"
                                            Checked="radioDefaultClickAction_Checked" Tag="Phone Call">
                                                <RadioButton.Content>
                                                    <Image Height="22" Width="19" Source="{DynamicResource callIcon}" VerticalAlignment="Center" ToolTip="Phone Call" Margin="-3,0,0,0"/>
                                                </RadioButton.Content>
                                        </RadioButton>
                                        <RadioButton x:Name="radioCommunicatorCall" GroupName="{Binding Path=Slot}" Margin="0 0 5 0" ToolTip="Communicator Call"
                                            IsEnabled="{Binding Path=IsPhoneNumber, Converter={StaticResource isPhoneNumberConverter}, Mode=OneWay}"
                                            IsChecked="{Binding Path=DefaultClickActionFriendlyName, Converter={StaticResource clickActionConverterCommunicatorCall}, Mode=OneWay}"
                                            Checked="radioDefaultClickAction_Checked" Tag="Communicator Call">
                                                <RadioButton.Content>
                                                    <Image Height="22" Width="19" Source="{DynamicResource comCallIcon}" VerticalAlignment="Center" ToolTip="Communicator Call" Margin="-3,0,0,0"/>
                                                </RadioButton.Content>
                                        </RadioButton>
                                        <Image x:Name="imgDelete" Tag="{Binding Path=Slot}" Width="14" Height="14" MouseDown="imgDelete_MouseDown" Source="{DynamicResource iconDelete}" VerticalAlignment="Center" Margin="15,0,0,0"/>
                                    </StackPanel>
                                </Grid>
                                <DataTemplate.Triggers>
                                    <DataTrigger Binding="{Binding Path=IsSelected, RelativeSource={RelativeSource AncestorType={x:Type ListBoxItem}, Mode=FindAncestor}}"  Value="true">
                                        <Setter TargetName="txtFav5ContactId" Property="Visibility" Value="Visible" />
                                        <Setter TargetName="lblFav5ContactId" Property="Visibility" Value="Collapsed" />
                                        <Setter TargetName="borderContactId" Property="Visibility" Value="Collapsed" />
                                        <Setter TargetName="txtFav5DisplayName" Property="Visibility" Value="Visible" />
                                        <Setter TargetName="lblFav5DisplayName" Property="Visibility" Value="Collapsed" />
                                        <Setter TargetName="borderDisplayName" Property="Visibility" Value="Collapsed" />
                                    </DataTrigger>
                                </DataTemplate.Triggers>
                            </DataTemplate>
                        </Grid.Resources>
                        
                        <StackPanel Orientation="Vertical">
                            <Grid x:Name="gridFav5Config" Focusable="True" Margin="0,10,0,0">
                                <ListBox x:Name="listFav5" 
                                    AllowDrop="True" 
                                    ItemTemplate="{StaticResource fav5EntryTemplate}" 
                                    Tag="{Binding Source={StaticResource clickActions}}"
                                    HorizontalAlignment="Left" 
                                    VerticalAlignment="Top"
                                    ScrollViewer.HorizontalScrollBarVisibility="Disabled" 
                                    ScrollViewer.VerticalScrollBarVisibility="Disabled" BorderBrush="{x:Null}" Background="{x:Null}"/>
                            </Grid>
                            
                            <Grid x:Name="gridMessage" Visibility="Collapsed" Margin="0,15,0,0">
                                <Border BorderBrush="#70FB350B" Background="#70FB350B" CornerRadius="2" Width="200" 
                                        BorderThickness="1" Padding="0" VerticalAlignment="Center" HorizontalAlignment="Center">
                		            <TextBlock x:Name="tbMessage" FontFamily="Calibri" FontSize="14" 
                                       Foreground="#FFFFFFFF" HorizontalAlignment="Center" Margin="0,0,0,0"
                                       VerticalAlignment="Center" TextWrapping="Wrap" />
                                </Border>
                            </Grid>
                            
                        </StackPanel>
                    </Grid>
                    
                    <Button x:Name="btnApply" Click="btnApply_Click" VerticalAlignment="Bottom" Content="Apply" Style="{DynamicResource BtnGeneric}" Width="60" Height="20" Margin="0,0,0,10"/>
                    <Button x:Name="btnCancel" Click="btnCancel_Click" VerticalAlignment="Bottom" HorizontalAlignment="Right" Content="Close" Style="{DynamicResource BtnGeneric}" Width="60" Height="20" Margin="0,0,50,10"/>
                    <Button Template="{DynamicResource ImageButton}" Height="29" Width="29" HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="0,0,10,5" x:Name="btnHelp">
                        <Image Width="29" Height="29" Source="Resources\Images\helpBtn.png" Stretch="Uniform" StretchDirection="DownOnly"/>
                    </Button>
                    <Grid x:Name="tooltip"  Opacity="0" Width="250" Height="350" VerticalAlignment="Bottom" Visibility="Hidden"  HorizontalAlignment="Right" Margin="0,0,26,13">
                    	<Image Source="{StaticResource toolTip}" />                    		
                    	<TextBlock Foreground="#FFFFFF" FontSize="8.7pt" Margin="17,60,40,20" TextWrapping="Wrap" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" TextAlignment="Left"><Run FontSize="9.3pt" Text="Fav 5 Setup Instructions"/><LineBreak /><LineBreak /><Run Foreground="#9FFFFFFF" Text="Add a contact to your Fav5 list by:"/><LineBreak /><LineBreak /><Run Foreground="#9FFFFFFF" Text="- Dragging a contact from Office Communicator 2007"/><LineBreak /><Run Foreground="#9FFFFFFF" Text="- Entering the contact's name"/><LineBreak /><Run Foreground="#9FFFFFFF" Text="- Entering the contact's Sip Uri"/><LineBreak /><Run Foreground="#9FFFFFFF" Text="- Entering a contact's phone number"/><LineBreak /><LineBreak /><Run Foreground="#9FFFFFFF" Text="Modify the contact's display name by editing the text in the second textbox."/></TextBlock>
                    </Grid>
    			</Grid>
            </Border>
        </Border>
    </Grid>
</Page>